//
//  LGBreathReportValueView.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/8/6.
//  训练报告-测量值

#import "LGBreathReportValueView.h"

@implementation LGBreathReportValueView

-(instancetype)initWithTitle:(NSString *)title titleArray:(NSArray *)titleArray frame:(CGRect)frame{
    self = [super initWithTitle:title frame:frame];
    if (self) {
        self.gradientLayer.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
        [self createSubViewWithTitleArray:titleArray];
    }
    return self;
}

-(void)createSubViewWithTitleArray:(NSArray *)titleArray{
    //表格
    CGFloat width1 = (Screen_W-viewPix(56))/2.0 - viewPix(11);
    CGFloat width2 = ((Screen_W-viewPix(56))/2.0 + viewPix(11))/2.0;
    UIView *baseView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(49), Screen_W-viewPix(56), viewPix(158))];
    [baseView addBorder:@"#E0E0E0" lineWidth:1 cornerRidus:2];
    [self addSubview:baseView];
    //蓝色背景
    UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_W-viewPix(56), viewPix(40))];
    titleView.backgroundColor = [UIColor colorWithString:@"#F3F9FF"];
    [baseView addSubview:titleView];
    
    //分割线 - H
    for (NSInteger i=0; i<4; i++) {
        UIView *lineView_H = [[UIView alloc]initWithFrame:CGRectMake(0, viewPix(40)*i, Screen_W-viewPix(56), 1)];
        lineView_H.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
        lineView_H.hidden = (i == 0)?YES:NO;
        [baseView addSubview:lineView_H];
        
        UILabel *titleLabel = [UILabel lableWithText:titleArray[i] colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
        titleLabel.frame = CGRectMake(viewPix(8), viewPix(40)*i, width1-viewPix(16), viewPix(40));
        [baseView addSubview:titleLabel];
    }
    
    //分割线 - V
    UIView *lineView_V1 = [[UIView alloc]initWithFrame:CGRectMake(width1, 0, 1, viewPix(158))];
    lineView_V1.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    [baseView addSubview:lineView_V1];
    
    UIView *lineView_V2 = [[UIView alloc]initWithFrame:CGRectMake(width1+width2, 0, 1, viewPix(158))];
    lineView_V2.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    [baseView addSubview:lineView_V2];
    
    //标题：计划、记录
    UILabel *titleLabel1 = [UILabel lableWithText:@"平均值" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel1.frame = CGRectMake(viewPix(8)+width1, 0, width1-viewPix(16), viewPix(40));
    [baseView addSubview:titleLabel1];
    
    UILabel *titleLabel2 = [UILabel lableWithText:@"最佳值" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel2.frame = CGRectMake(viewPix(8)+width1+width2, 0, width2-viewPix(16), viewPix(40));
    [baseView addSubview:titleLabel2];
    
    //值
    self.averageLabel1.frame = CGRectMake(kMinX(titleLabel1.frame), kMaxY(titleLabel1.frame), width2-viewPix(10), viewPix(40));
    self.averageLabel2.frame = CGRectMake(kMinX(titleLabel1.frame), kMaxY(self.averageLabel1.frame), width2-viewPix(10), viewPix(40));
    self.averageLabel3.frame = CGRectMake(kMinX(titleLabel1.frame), kMaxY(self.averageLabel2.frame), width2-viewPix(10), viewPix(40));
    self.optimalLabel1.frame = CGRectMake(kMinX(titleLabel2.frame), kMaxY(titleLabel2.frame), width2-viewPix(10), viewPix(40));
    self.optimalLabel2.frame = CGRectMake(kMinX(titleLabel2.frame), kMaxY(self.optimalLabel1.frame), width2-viewPix(10), viewPix(40));
    self.optimalLabel3.frame = CGRectMake(kMinX(titleLabel2.frame), kMaxY(self.optimalLabel2.frame), width2-viewPix(10), viewPix(40));
    [baseView addSubview:self.averageLabel1];
    [baseView addSubview:self.averageLabel2];
    [baseView addSubview:self.averageLabel3];
    [baseView addSubview:self.optimalLabel1];
    [baseView addSubview:self.optimalLabel2];
    [baseView addSubview:self.optimalLabel3];
}

-(UILabel *)averageLabel1{
    if(!_averageLabel1){
        _averageLabel1 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _averageLabel1;
}

-(UILabel *)averageLabel2{
    if(!_averageLabel2){
        _averageLabel2 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _averageLabel2;
}

-(UILabel *)averageLabel3{
    if(!_averageLabel3){
        _averageLabel3 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _averageLabel3;
}

-(UILabel *)optimalLabel1{
    if(!_optimalLabel1){
        _optimalLabel1 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _optimalLabel1;
}

-(UILabel *)optimalLabel2{
    if(!_optimalLabel2){
        _optimalLabel2 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _optimalLabel2;
}

-(UILabel *)optimalLabel3{
    if(!_optimalLabel3){
        _optimalLabel3 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _optimalLabel3;
}


@end
